package test.light.utils;

import org.junit.Test;
import org.light.domain.Domain;
import org.light.domain.Field;
import org.light.utils.CompareUtil;

import junit.framework.Assert;

public class CompareUtilTest {
	@Test
	public void testCompareField(){
		Field f1 = new Field("myname","string");
		Field f2 = new Field("myname","String");
		Assert.assertTrue(CompareUtil.compareField(f1, f2));
		
		Field fi1 = new Field("myname","image");
		Field fi2 = new Field("myname","Image");
		Assert.assertTrue(CompareUtil.compareField(fi1, fi2));
		
		Field fs1 = new Field("myname2","string");
		Field fs2 = new Field("myname","String");
		Assert.assertFalse(CompareUtil.compareField(fs1, fs2));
	}
	
	@Test
	public void testCompareDomain() throws Exception{
		Field f1 = new Field("myfield","string");
		Field fi2 = new Field("myimage","Image");
		Domain d0 = new Domain();
		d0.setStandardName("MyDomain");
		d0.setVerbDeniesStr("max+,Add,Update,Activate,ActivateAll");
		d0.setDomainId(new Field("id","Long"));
		d0.setDomainName(new Field("myName","string"));
		d0.setActive(new Field("active","boolean"));
		d0.addField(f1);
		d0.addField(fi2);
		//d0.addField(new Field("field2","string"));
		
		Domain d1 = new Domain();
		d1.setVerbDeniesStr("Clone,CloneAll,Delete,DeleteAll,Export,ExportPDF,ExportPPT,ExportWord,FilterExcel,FilterPDF,FilterPPT,FilterWord,FindByName,ListAllByPage,SearchByFields,SearchByName,SoftDelete,SoftDeleteAll,Toggle,ToggleOne,View");
		d1.setStandardName("MyDomain");
		d1.setDomainId(new Field("id","long"));
		d1.setDomainName(new Field("myName","String"));
		d1.setActive(new Field("active","Boolean"));
		d1.addField(f1);
		d1.addField(fi2);
		Assert.assertTrue(CompareUtil.compareDomain(d0, d1));
	}
}